<?php

if(!defined('IN_T')){
   die('hacking attempt');
}


class module_company_member extends module_public_member{

	//重写提取管理员列表
	protected function index(){
		global $tp;
		global $Json;
		$priv = $this->get_priv_list();
		foreach ($priv['res'] as $key => $value) {
			$priv['res'][$key]['privileges']=$Json->decode($value['privileges']);
		}
		// var_dump($priv);
		$tp->assign('res',$priv);
	}

	//商户号编辑member
	protected function detail(){
		global $Json;
		$id = module_public_member::edit();
		if($id){
			$res = array('status'=>1,'msg'=>'提交成功','href'=>'/'.COMPANY_PATH.'/?m=member');
			echo $Json->encode($res);
			exit;
		}
		
	}

	//屏蔽员工帐号
	protected function is_not(){
		
		module_public_member::dismember();
	}


	protected function get_priv_list($id){
	   $sql = "from ".$GLOBALS['Base']->table('company')." where p_id=".$GLOBALS['company']['id']."";
	   if($id){
	   	$sql .= " WHERE id =$id ";
	   }
	   $rescount = $GLOBALS['Db']->query("SELECT COUNT(*) AS num " .$sql,"One");
	   $sql = "select * ".$sql." order by id DESC ";
	   $res = $GLOBALS['Db']->query($sql);
	   return array('res'=>$res);
	}
}

new module_company_member();

?>